﻿using System;

namespace EpiNEXT.Core.Validation.Functions
{
    public sealed class Month : DateComponentBase
    {
        public Month()
            : base()
        {

        }

        public override object Execute(Record record, params object[] parameters)
        {
            if (parameters == null || parameters.Length == 0 || parameters[0] == null || String.IsNullOrEmpty(parameters[0].ToString().Trim()))
            {
                return null;
            }

            DateTime? date = GetDate(parameters[0], record);

            if (date.HasValue)
            {
                return date.Value.Month;
            }
            else
            {
                return null;
            }
        }
    }
}
